package tracks.controllers.methods.MCTS;

import java.util.Random;

import core.game.StateObservation;
import ontology.Types;
import tools.ElapsedCpuTimer;

public class SingleMCTSPlayer
{
    public SingleTreeNode m_root;
    public Random m_rnd;
    public SingleMCTSPlayer(Random a_rnd)
    {
        m_rnd = a_rnd;
        m_root = new SingleTreeNode(a_rnd);
    }

    public void init(StateObservation a_gameState)
    {
        m_root = new SingleTreeNode(a_gameState, null, m_rnd);

    }

    public Types.ACTIONS run(ElapsedCpuTimer elapsedTimer)
    {
        //Do the search within the available time.
        m_root.mctsSearch(elapsedTimer);

        //Determine the best action to take and return it.
        Types.ACTIONS action = m_root.mostVisitedAction();
        //int action = m_root.bestAction();
        return action;
    }

}